/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Times.java
 *
 * Created on Nov 4, 2010, 8:58:54 PM
 */

package lmclogistics;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;

/**
 *
 * @author katrina
 */
public class Times extends javax.swing.JPanel {

    private JComboBox hours = new JComboBox();
    private JComboBox mins = new JComboBox();
    /** Creates new form Times */
    public Times() {
        initComponents();
        setOpaque(false);
        setSize(287, 340);
        initCBox();
    }

    public void initCBox()
    {
        hours.removeAllItems();
        mins.removeAllItems();
        Hours();
        Mins();
    }

    public void Hours()
    {

        DefaultComboBoxModel model;

        String[] hrs = new String[] {"<Hr>", "00",
                                        "01", "02", "03", "04", "05",
                                        "06", "07", "08", "09", "10",
                                        "11", "12", "13", "14", "15",
                                        "16", "17", "18", "19", "20",
                                        "21", "22", "23"} ;

        model = new DefaultComboBoxModel(hrs);


        hours.setModel(model);

        hours.setLocation(0,0);
        hours.setSize(70,25);
        add(hours);
    }

    public void Mins()
    {

        DefaultComboBoxModel model;

        String[] min = new String[] {"<Min>", "00",
                                        "01", "02", "03", "04", "05",
                                        "06", "07", "08", "09", "10",
                                        "11", "12", "13", "14", "15",
                                        "16", "17", "18", "19", "20",
                                        "21", "22", "23", "24", "25",
                                        "26", "27", "28", "29", "30",
                                        "31", "32", "33", "34", "35",
                                        "36", "37", "38", "39", "40",
                                        "41", "42", "43", "44", "45",
                                        "46", "47", "48", "49", "50",
                                        "51", "52", "53", "54", "55",
                                        "56", "57", "58", "59"} ;

        model = new DefaultComboBoxModel(min);


        mins.setModel(model);

        mins.setLocation(73,0);
        mins.setSize(70,25);
        add(mins);
    }

    public String getTime()
    {
        int hrVal = hours.getSelectedIndex()-1;
        String hrStr="";
        if(hrVal<10)
            hrStr = "0"+hrVal;
        int minVal = mins.getSelectedIndex()-1;
        String minStr="";
        if(minVal<10)
            minStr = "0"+minVal;

        String time = hrStr+minStr+"00";
        return time;
    }

     public void initTimes(int width, int height, int x, int y)
    {
        initCBox();
        setSize(width, height);
        setLocation(x, y);
    }

     public boolean checkTime(){
         if(hours.getSelectedIndex()==0 || mins.getSelectedIndex()==0)
             return false;
         else
             return true;
     }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
